﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Locator.BusinessEntities;

namespace Locator.Inventory
{
    public class InventoryRequest
    {
        public int ProductId { get; set; }

        public ProductIdType ProductIdType { get; set; }

        public int StoreNumber { get; set; }

        public StoreNumberType StoreNumberType { get; set; }

        public List<int> GetProductsToFind(User userEntity)
        {
            List<int> productsToFind = new List<int>();
            if (ProductIdType == ProductIdType.AllUsersProducts)
            {
                var usersProductIds = from p in userEntity.Products2 select p.ProductNumber;
                productsToFind.AddRange(usersProductIds);
            }
            else
            {
                productsToFind.Add(ProductId);
            }

            return productsToFind;
        }

        public IEnumerable<int> GetStoreIds(DrinksEntities entities, User userEntity)
        {
            IEnumerable<int> storeids;
            if (StoreNumberType == StoreNumberType.AllStores)
            {
                storeids = from s in entities.StoreInformations select s.StoreNumber;
            }
            else
            {
                if (StoreNumberType == StoreNumberType.AllUsersStores)
                {
                    storeids = from s in userEntity.StoreInformations select s.StoreNumber;
                }
                else
                {
                    storeids = new int[] { StoreNumber };
                }
            }

            return storeids;
        }
    }
}